package com.mini.service.impl;

import com.mini.dao.ServerInfoMapper;
import com.mini.pojo.basic.ServerInfo;
import com.mini.service.ServerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ServerInfoServiceImpl implements ServerInfoService {

    @Autowired
    private ServerInfoMapper serverInfoMapper;

    public void addServerInfo(ServerInfo serverInfo) {
        serverInfo.setCreatedBy("test");
        serverInfo.setCreatedTime(new Date());
        serverInfo.setUpdatedBy("test");
        serverInfo.setUpdatedTime(new Date());
        serverInfoMapper.addServerInfo(serverInfo);
    }

    public void updateServerInfo(ServerInfo serverInfo) {
        serverInfo.setUpdatedBy("test");
        serverInfo.setUpdatedTime(new Date());
        serverInfoMapper.updateServerInfo(serverInfo);
    }

    public int removeServerInfo(int serverInfoId) {
        ServerInfo serverInfo = serverInfoMapper.queryServerInfo(serverInfoId);
        serverInfo.setUpdatedBy("test");
        serverInfo.setUpdatedTime(new Date());
        return serverInfoMapper.removeServerInfo(serverInfo);
    }

    public ServerInfo queryServerInfo(int serverinfoId) {
        return serverInfoMapper.queryServerInfo(serverinfoId);
    }

    public List<ServerInfo> queryAllServerInfo() {
        return serverInfoMapper.queryAllServerInfo();
    }
}
